home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 109
/
Vol 109.iso
/
games
/
chicken_.swf
/
scripts
/
frame_4
/
DoAction.as
Wrap
Text File
|
2008-11-12
|
3KB
|
135 lines
function initMeat()
{
i = 0;
while(i < 5)
{
var obj = this["meat_" + i];
this["as_" + i].num = i;
obj.num = i;
obj.click = true;
obj.onPress = function()
{
if(this.click)
{
_root["as_" + this.num].stop();
this._root.depths += _root.depths <= _root.depthsMax ? 1 : -1000;
this.swapDepths(_root.depths);
this.startDrag();
_root.changeSide(this.num);
_root.showRipe(this.num);
}
};
obj.onRelease = function()
{
if(this.click)
{
this.stopDrag();
if(_root.hit_fire.hitTest(this._x,this._y,true))
{
_root.setSite(this.num,this._x,this._y);
_root.showDirection(this.num);
_root["as_" + this.num].play();
_root.sound_mc.gotoAndPlay(2);
}
else if(_root.hit_dish.hitTest(this._x,this._y,true))
{
this.click = false;
_root.setSite(this.num,this._x,this._y);
_root.showDirection(this.num);
_root["as_" + this.num].gotoAndPlay("ok");
}
else
{
_root.getSite(this.num);
}
}
};
var direction = random(2) + 1;
obj.gotoAndStop(direction);
obj._visible = true;
meat_list[i] = new meatClass(direction,obj._x,obj._y);
i++;
}
}
function meatClass(direction, x, y)
{
this.direction = direction;
this.side = 0;
this.ripe = [1,1];
this.count = [0,0];
this.sx = this.x = x;
this.sy = this.y = y;
this.reset = function()
{
this.side = 0;
this.ripe = [1,1];
this.count = [0,0];
this.x = this.sx;
this.y = this.sy;
};
}
function resetMeat(num)
{
meat_list[num].reset();
var obj = this["meat_" + num];
meat_list[num].direction = random(2) + 1;
showDirection(num);
getSite(num);
obj._visible = true;
obj.click = true;
}
function changeHP()
{
HP++;
hp_mc.gotoAndStop(HP);
if(HP > 10)
{
gotoAndPlay(16);
}
}
function changeSide(num)
{
var side = meat_list[num].side;
side += side <= 0 ? 1 : -1;
meat_list[num].side = side;
}
function changeDirection(num)
{
var direction = meat_list[num].direction;
direction += direction <= 1 ? 1 : -1;
meat_list[num].direction = direction;
return direction;
}
function getRipe(num)
{
var side = meat_list[num].side;
var ripe = meat_list[num].ripe[side];
var frame = side * 5 + ripe;
return frame;
}
function showRipe(num)
{
var ripe = getRipe(num);
_root["meat_" + num].meat_mc.gotoAndStop(ripe);
}
function showDirection(num)
{
var direction = changeDirection(num);
_root["meat_" + num].gotoAndStop(direction);
showRipe(num);
}
function setSite(num, x, y)
{
meat_list[num].x = x;
meat_list[num].y = y;
}
function getSite(num)
{
_root["meat_" + num]._x = meat_list[num].x;
_root["meat_" + num]._y = meat_list[num].y;
}
ripeTime = 20;
timeOut = 45;
score_list = [0,1,10,5,0];
plus_list = ["","a","c","b",""];